import React,{ useState } from 'react';
import useLocal from './hooks/local';




function App() {
  const [query, setQuery] = useState('');



  // 返回值
  const [todos,setTodos]=useLocal('todos',['买牛奶','刷LeetCode'])  // 自定义的hooks函数

  function onClick(){
    setTodos([...todos,query])
    setQuery('');
  }

  return (
    <div className="App">
      <input type="text" value={query} onChange={e=>setQuery(e.target.value)} />
      <button onClick={onClick}>create</button>
      <ul>
        {
          todos.map((todo,index)=>(<li key={index}>{todo}</li>))
        }
      </ul>
    </div>
  )
}

export default App;
